vulkan: Fix swapchain creation
authorMatthias Clasen <mclasen@redhat.com>
Thu, 10 Sep 2020 17:55:16 +0000 (13:55 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 10 Sep 2020 17:55:16 +0000 (13:55 -0400)
We end up with a surface that has size 0x0 at the
time we create the Vulkan context, and that is a
size that Vulkan doesn't like, so ensure we request
at least 1x1.

Fixes: #3147
gdk/gdkvulkancontext.c

index d4c36a7cd07f10e27c2cdd23e29c115dcba43ea1..917b443f94995105d1853462455adad1bafd8b48 100644 (file)
@@ -324,13 +324,13 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext  *context,
 
   /*
    * Per https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkSurfaceCapabilitiesKHR
-   * the current extent may assume a special value, meaning that the extend should assume whatever
+   * the current extent may assume a special value, meaning that the extent should assume whatever
    * value the surface has.
    */
   if (capabilities.currentExtent.width == -1 || capabilities.currentExtent.height == -1)
     {
-      capabilities.currentExtent.width = gdk_surface_get_width (surface) * gdk_surface_get_scale_factor (surface);
-      capabilities.currentExtent.height = gdk_surface_get_height (surface) * gdk_surface_get_scale_factor (surface);
+      capabilities.currentExtent.width = MAX (1, gdk_surface_get_width (surface) * gdk_surface_get_scale_factor (surface));
+      capabilities.currentExtent.height = MAX (1, gdk_surface_get_height (surface) * gdk_surface_get_scale_factor (surface));
     }
 
   res = GDK_VK_CHECK (vkCreateSwapchainKHR, device,